package main

import (
	"TheTearAfter/models"
	"TheTearAfter/mysql"
	"TheTearAfter/routers"
	"TheTearAfter/service"
	"TheTearAfter/test"
	"fmt"
)

func main() {
	// 数据库
	err := mysql.SqlInit()
	if err != nil {
		fmt.Println("mysql.SqlInit Err:", err)
	}

	modelsList := []interface{}{
		&models.MessageBlock{},
		&models.MessageTypeClass{},
		&models.MessageTypeClass_Link_MessageBlock{},
	}
	// 自动迁移
	mysql.DB.AutoMigrate(modelsList...)
	defer mysql.Close()

	// 测试用
	test.Test()

	// 定时爬取服务启动
	service.TickUpdata(30000, 16)

	r := routers.SetupRouters()
	err = r.Run("localhost:5050")

	if err != nil {
		fmt.Println("r.Run Err:", err)
	}
}
